package cn.edu.gzhu.workOrderManagement.service.impl;

import cn.edu.gzhu.workOrderManagement.constants.WorkOrderFollowStatus;
import cn.edu.gzhu.workOrderManagement.constants.WorkOrderTypeConstant;
import cn.edu.gzhu.workOrderManagement.enumeration.UserAuthorityEnum;
import cn.edu.gzhu.workOrderManagement.enumeration.WorkOrderProcessingStatusEnum;
import cn.edu.gzhu.workOrderManagement.mapper.OrganizationMapper;
import cn.edu.gzhu.workOrderManagement.mapper.UserMapper;
import cn.edu.gzhu.workOrderManagement.mapper.WorkOrderMapper;
import cn.edu.gzhu.workOrderManagement.pojo.dto.user.UserListDto;
import cn.edu.gzhu.workOrderManagement.pojo.dto.workOrder.WorkOrderCreateDto;
import cn.edu.gzhu.workOrderManagement.pojo.dto.workOrder.WorkOrderListDto;
import cn.edu.gzhu.workOrderManagement.pojo.dto.workOrder.WorkOrderRepeatDto;
import cn.edu.gzhu.workOrderManagement.pojo.dto.workOrder.WorkOrderUpdateDto;
import cn.edu.gzhu.workOrderManagement.pojo.entity.Organization;
import cn.edu.gzhu.workOrderManagement.pojo.entity.User;
import cn.edu.gzhu.workOrderManagement.pojo.entity.WorkOrder;
import cn.edu.gzhu.workOrderManagement.pojo.vo.*;
import cn.edu.gzhu.workOrderManagement.service.OrganizationService;
import cn.edu.gzhu.workOrderManagement.service.UserService;
import cn.edu.gzhu.workOrderManagement.service.WorkOrderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;



@Service
public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper,WorkOrder> implements WorkOrderService {

    @Autowired
    UserService userService;
    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    SensitiveWordBs sensitiveWordBs;
    @Autowired
    OrganizationService organizationService;
    @Autowired
    OrganizationMapper organizationMapper;
    @Autowired
    UserMapper userMapper;
    @Autowired
    WorkOrderMapper workOrderMapper;
    /**
     * 批量创建工单
     *
     * @param workOrderCreateDtos
     * @return
     */
    /*
    插入前需要填充uuid,followStatus,processingStatus,targetUser,createTime
     */


    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean createWorkOrder(List<WorkOrderCreateDto> workOrderCreateDtos) {
        List<WorkOrder> workOrders = new ArrayList<>();

        for (WorkOrderCreateDto workOrderCreateDto : workOrderCreateDtos) {
            String tu = workOrderCreateDto.getTargetUser();
            User user1 = userMapper.selectOne(new QueryWrapper<User>().eq("username", tu));
            if (!user1.getAuthority().equals(UserAuthorityEnum.HEAD_BUSINESS)) {
                IPage<UserVo> voIPage = userService.listByConditions(UserListDto.builder()
                        .authority(UserAuthorityEnum.BRANCH_BUSINESS)
                        .organization(workOrderCreateDto.getTargetOrganization())
                        .startPage(0).pageSize(10).build());
                if (voIPage.getTotal() == 0) return false;
                List<UserVo> branchBusiness = voIPage.getRecords();
                if (workOrderCreateDto.getTargetUser() == null) {
                    workOrderCreateDto.setTargetUser(branchBusiness.get(0).getUsername());
                } else if (branchBusiness.stream().noneMatch(user -> user.getUsername().equals(workOrderCreateDto.getTargetUser()))) {
                    return false;
                }
            }

            WorkOrder workOrder = new WorkOrder();
            BeanUtils.copyProperties(workOrderCreateDto, workOrder);
            Integer adder  =0;

            String uuid = generateUniqueUuid(workOrder.getType(),adder);

            while(workOrderMapper.selectOne(new QueryWrapper<WorkOrder>().eq("uuid", uuid))!=null){
                adder+=1;
                uuid = generateUniqueUuid(workOrder.getType(),adder);
            }

            workOrder.setUuid(uuid);

            workOrder.setCreateTime(LocalDateTime.now());
            workOrder.setUpdateTime(LocalDateTime.now());
            workOrder.setFollowStatus(WorkOrderFollowStatus.WAITING);
            workOrder.setRepeatTime(0);
            workOrder.setIsSensitive(sensitiveWordBs.contains(workOrder.getContent()));
            workOrder.setIs_deleted(false);
            User targetUser = userMapper.selectOne(new QueryWrapper<User>().eq("username", workOrderCreateDto.getTargetUser()));
            workOrder.setProcessingStatus(determineProcessingStatus(workOrder.getType(), targetUser.getAuthority()));
            if (workOrder.getProcessingStatus() == null) return false;

            workOrders.add(workOrder);
        }
        boolean isSuccess = saveBatch(workOrders);
        if (isSuccess) {
            for (WorkOrder workOrder : workOrders) {
                redisTemplate.opsForValue().set(workOrder.getUuid(), workOrder, Duration.between(LocalDateTime.now(), workOrder.getExpectedEndTime()));
            }
        }
        return isSuccess;
    }

    private String generateUniqueUuid(String type,Integer adder) {
        String prefix = switch (type) {
            case WorkOrderTypeConstant.COMMON -> "C";
            case WorkOrderTypeConstant.REPEAT -> "R";
            case WorkOrderTypeConstant.MATERIAL -> "M";
            default -> "X";
        };
        LocalDate localDate = LocalDate.now();
        String formatDate = localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));

        LocalDateTime startOfDay = localDate.atStartOfDay();
        LocalDateTime endOfDay = localDate.atTime(23, 59, 59);
        LambdaQueryWrapper<WorkOrder> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(WorkOrder::getType, type);
        wrapper.ge(WorkOrder::getCreateTime, startOfDay);
        wrapper.le(WorkOrder::getCreateTime, endOfDay);

        int count = this.count(wrapper) + 1;
        count = count+adder;
        return prefix + formatDate + count;
    }

    private WorkOrderProcessingStatusEnum determineProcessingStatus(String type, UserAuthorityEnum authority) {
        return switch (type) {
            case WorkOrderTypeConstant.COMMON -> authority.equals(UserAuthorityEnum.BRANCH_BUSINESS) ?
                    WorkOrderProcessingStatusEnum.COMMON_BRANCH_BUS_PENDING :
                    authority.equals(UserAuthorityEnum.HEAD_BUSINESS) ?
                            WorkOrderProcessingStatusEnum.COMMON_HEAD_BUS_PENDING : null;
            case WorkOrderTypeConstant.REPEAT -> authority.equals(UserAuthorityEnum.BRANCH_BUSINESS) ?
                    WorkOrderProcessingStatusEnum.REPEAT_BRANCH_BUS_PENDING :
                    authority.equals(UserAuthorityEnum.HEAD_BUSINESS) ?
                            WorkOrderProcessingStatusEnum.REPEAT_HEAD_BUS_PENDING : null;
            case WorkOrderTypeConstant.MATERIAL -> authority.equals(UserAuthorityEnum.BRANCH_BUSINESS) ?
                    WorkOrderProcessingStatusEnum.MATERIAL_BRANCH_BUS_PENDING :
                    authority.equals(UserAuthorityEnum.HEAD_BUSINESS) ?
                            WorkOrderProcessingStatusEnum.MATERIAL_HEAD_BUS_PENDING : null;
            default -> null;
        };
    }

    /**
     * 更新工单
     *
     * @param workOrderUpdateDto
     * @return
     */
    @Override

    public Boolean updateWorkOrder(WorkOrderUpdateDto workOrderUpdateDto) {
        //先校验要更新的工单是否存在
        IPage<WorkOrderVo> workOrderVoIPage = listWorkOrder(WorkOrderListDto.builder().uuid(workOrderUpdateDto.getUuid()).needDetails(false).startPage(1).pageSize(10).build());
        List<WorkOrderVo> records = workOrderVoIPage.getRecords();
        if (records.isEmpty()) {
            return false;
        }
        //再校验目标组织和目标用户是否存在,用mapper而不是service，因为不能模糊查询
        LambdaUpdateWrapper<Organization> organizationLambdaUpdateWrapper = new LambdaUpdateWrapper<Organization>().eq(Organization::getName, workOrderUpdateDto.getTargetOrganization());
        LambdaQueryWrapper<User> userLambdaQueryWrapper = new LambdaQueryWrapper<User>().eq(User::getUsername,workOrderUpdateDto.getTargetUser());
        User user = userMapper.selectOne(userLambdaQueryWrapper);
        Organization organization = organizationMapper.selectOne(organizationLambdaUpdateWrapper);
        if (organization==null||user==null|| !Objects.equals(user.getOrganization(), organization.getName())) {
            return false;
        }
        LambdaUpdateWrapper<WorkOrder> updateWrapper = new LambdaUpdateWrapper<>();
        //根据uuid定位
        updateWrapper.eq(WorkOrder::getUuid, workOrderUpdateDto.getUuid());

        updateWrapper.set(WorkOrder::getUpdateTime, LocalDateTime.now());

        //如果是主管转单给处理员，则不需要更新处理状态
        if (!workOrderUpdateDto.getNeedsReassignment()) {
            //处理跟进状态和工单状态
            WorkOrderVo targetWorkOrder = records.get(0);
            //根据前端传入的isAdvance判断是进入下一状态还是返回上一级
            WorkOrderProcessingStatusEnum nextStatus = null;

            if (workOrderUpdateDto.getIsAdvance()) {
                nextStatus = targetWorkOrder.getProcessingStatus().toNextStatus();
            }
            if (!workOrderUpdateDto.getIsAdvance()) {
                nextStatus = targetWorkOrder.getProcessingStatus().toPreviousStatus();
            }
            if (nextStatus == null) {
                return false;
            }

            //更新跟进状态
            String workOrderFollowStatus = null;
            if (nextStatus.equals(WorkOrderProcessingStatusEnum.getCommonStartStatus())
                    || nextStatus.equals(WorkOrderProcessingStatusEnum.getRepeatStartStatus())
                    || nextStatus.equals(WorkOrderProcessingStatusEnum.getMaterialStartStatus())) {
                workOrderFollowStatus = WorkOrderFollowStatus.WAITING;
            } else if (nextStatus.equals(WorkOrderProcessingStatusEnum.getCommonEndStatus())
                    || nextStatus.equals(WorkOrderProcessingStatusEnum.getRepeatEndStatus())
                    || nextStatus.equals(WorkOrderProcessingStatusEnum.getMaterialEndStatus())) {
                workOrderFollowStatus = WorkOrderFollowStatus.END;
                updateWrapper.set(WorkOrder::getEndTime, LocalDateTime.now());
            } else {
                workOrderFollowStatus = WorkOrderFollowStatus.FOLLOWING;
            }
            updateWrapper.set(WorkOrder::getFollowStatus, workOrderFollowStatus);
            updateWrapper.set(WorkOrder::getProcessingStatus, nextStatus);
        }
        WorkOrder workOrder = new WorkOrder();
        //必须用实体类，否则自定义类转换器不生效
        BeanUtils.copyProperties(workOrderUpdateDto, workOrder,"uuid");
        workOrder.setIs_deleted(false);
        // 执行更新并返回结果
        return update(workOrder,updateWrapper);
    }


    /**
     * 批量删除工单
     *
     * @param uuids
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteWorkOrder(List<String> uuids) {
        boolean deleteResult = update()
                .set("is_deleted", true)
                .in("uuid", uuids)
                .update();

        if (deleteResult) {
            uuids.forEach(uuid -> redisTemplate.delete(uuid));
        }
        return deleteResult;
    }

    /**
     * 工单分页查询
     *
     * @param workOrderListDto
     * @return
     */
    @Override
    public IPage<WorkOrderVo> listWorkOrder(WorkOrderListDto workOrderListDto) {
        //添加查询条件
        LambdaQueryWrapper<WorkOrder> queryWrapper = getWorkOrderLambdaQueryWrapper(workOrderListDto);

        // 分页查询
        Page<WorkOrder> page = new Page<>(workOrderListDto.getStartPage(), workOrderListDto.getPageSize());
        IPage<WorkOrder> workOrderPage = this.page(page, queryWrapper);

        List voList;
        // 转换为 VO
        if (workOrderListDto.getNeedDetails()) {
            voList = workOrderPage.getRecords().stream()
                    .map(workOrder -> {
                        WorkOrderDetailVo workOrderDetailVo = new WorkOrderDetailVo();
                        BeanUtils.copyProperties(workOrder, workOrderDetailVo);
                        return workOrderDetailVo;
                    }).collect(Collectors.toList());
        }
        else {
            voList = workOrderPage.getRecords().stream()
                    .map(workOrder -> {
                        WorkOrderListVo workOrderListlVo = new WorkOrderListVo();
                        BeanUtils.copyProperties(workOrder, workOrderListlVo);
                        return workOrderListlVo;
                    }).collect(Collectors.toList());
        }
        IPage<WorkOrderVo> voPage = new Page<>(workOrderPage.getCurrent(), workOrderPage.getSize(), workOrderPage.getTotal());
        voPage.setRecords(voList);
        return voPage;
    }

    /**
     * 重诉工单
     * @param workOrderRepeatDto
     * @return
     */
    @Override
    public Boolean repeatWorkOrder(WorkOrderRepeatDto workOrderRepeatDto) {
        IPage<WorkOrderVo> workOrderVoIPage = listWorkOrder(WorkOrderListDto.builder().uuid(workOrderRepeatDto.getUuid()).needDetails(true).startPage(1).pageSize(10).build());
        List<WorkOrderVo> records = workOrderVoIPage.getRecords();
        if (records.isEmpty()) {
            return false;
        }
        WorkOrderDetailVo targetWorkOrder =(WorkOrderDetailVo) records.get(0);
        //工单完结前不能重诉
        if (!Objects.equals(targetWorkOrder.getFollowStatus(), WorkOrderFollowStatus.END)) {
            return false;
        }
        LambdaUpdateWrapper<WorkOrder> repeatWrapper = new LambdaUpdateWrapper<>();
        //工单状态重设为待处理
        repeatWrapper.set(WorkOrder::getFollowStatus, WorkOrderFollowStatus.WAITING);
        //如果是材料工单则流程不变,非材料工单则设置为重诉工单
        if (!targetWorkOrder.getType().equals(WorkOrderTypeConstant.MATERIAL)) {
            repeatWrapper.set(WorkOrder::getType, WorkOrderTypeConstant.REPEAT);
            repeatWrapper.set(WorkOrder::getProcessingStatus, WorkOrderProcessingStatusEnum.getRepeatStartStatus());
        }
        repeatWrapper.set(WorkOrder::getProcessingStatus, WorkOrderProcessingStatusEnum.getMaterialStartStatus());
        repeatWrapper.set(WorkOrder::getRepeatTime,targetWorkOrder.getRepeatTime()+1);

        repeatWrapper.set(WorkOrder::getTargetOrganization, workOrderRepeatDto.getTargetOrganization());
        repeatWrapper.set(WorkOrder::getTargetUser, workOrderRepeatDto.getTargetUser());
        if (workOrderRepeatDto.getAlertLevel()!=null){
            repeatWrapper.set(WorkOrder::getAlertLevel, workOrderRepeatDto.getAlertLevel());
        }
        repeatWrapper.set(WorkOrder::getExpectedEndTime,workOrderRepeatDto.getExpectedEndTime());
        repeatWrapper.eq(WorkOrder::getUuid,workOrderRepeatDto.getUuid());

        return update(repeatWrapper);
    }

    //添加数据库相关条件的方法
    private static LambdaQueryWrapper<WorkOrder> getWorkOrderLambdaQueryWrapper(WorkOrderListDto workOrderListDto) {
        LambdaQueryWrapper<WorkOrder> queryWrapper = new LambdaQueryWrapper<>();

        // 条件构造
        if (StringUtils.isNotBlank(workOrderListDto.getUuid())) {
            // 根据工单唯一标识进行精确匹配（UUID具有全局唯一性）
            queryWrapper.eq(WorkOrder::getUuid, workOrderListDto.getUuid());
        }
        if (workOrderListDto.getCreateTime() != null) {
            // 创建时间范围查询：匹配指定日期的全天记录（00:00:00 ~ 23:59:59）
            LocalDate createTime = workOrderListDto.getCreateTime();
            LocalDateTime start = createTime.atStartOfDay();
            LocalDateTime end = createTime.atTime(LocalTime.MAX);
            queryWrapper.between(WorkOrder::getCreateTime, start,end);
        }
        if (workOrderListDto.getUpdateTime() != null) {
            // 最后更新时间范围查询：匹配指定日期的修改记录
            LocalDate updateTime = workOrderListDto.getUpdateTime();
            LocalDateTime start = updateTime.atStartOfDay();
            LocalDateTime end = updateTime.atTime(LocalTime.MAX);
            queryWrapper.between(WorkOrder::getUpdateTime, start,end);
        }
        if (StringUtils.isNotBlank(workOrderListDto.getRequestUser())) {
            // 请求人姓名精确匹配（需完全一致）
            queryWrapper.eq(WorkOrder::getRequestUser, workOrderListDto.getRequestUser());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getRequestIdCard())) {
            // 请求人身份证号精确匹配（用于身份核验场景）
            queryWrapper.eq(WorkOrder::getRequestIdCard, workOrderListDto.getRequestIdCard());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getLogicalCardNumber())) {
            // 逻辑卡号精确匹配（如虚拟卡业务标识）
            queryWrapper.eq(WorkOrder::getLogicalCardNumber, workOrderListDto.getLogicalCardNumber());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getCaseNumber())) {
            // 关联案件编号精确匹配（与外部系统关联时使用）
            queryWrapper.eq(WorkOrder::getCaseNumber, workOrderListDto.getCaseNumber());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getType())) {
            // 工单类型精确匹配（如：投诉/咨询/故障申报）
            queryWrapper.eq(WorkOrder::getType, workOrderListDto.getType());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getCategory())) {
            // 工单分类精确匹配（业务细分类型，如网络故障/账户问题）
            queryWrapper.eq(WorkOrder::getCategory, workOrderListDto.getCategory());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getFollowStatus())) {
            // 跟进状态匹配（如：待处理/处理中/已关闭）
            queryWrapper.eq(WorkOrder::getFollowStatus, workOrderListDto.getFollowStatus());
        }
        if (workOrderListDto.getAlertLevel() != null) {
            // 预警级别匹配（数字类型，如：1-普通 2-紧急 3-特急）
            queryWrapper.eq(WorkOrder::getAlertLevel, workOrderListDto.getAlertLevel());
        }
        if (workOrderListDto.getIsRegulatoryComplaint() != null) {
            // 是否监管投诉工单（布尔类型，特殊标记工单）
            queryWrapper.eq(WorkOrder::getIsRegulatoryComplaint, workOrderListDto.getIsRegulatoryComplaint());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getRegion())) {
            // 所属行政区域匹配（如：华北区/华东区）
            queryWrapper.eq(WorkOrder::getRegion, workOrderListDto.getRegion());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getHandler())) {
            // 当前处理人精确匹配（直接责任人查询）
            queryWrapper.eq(WorkOrder::getHandler, workOrderListDto.getHandler());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getManager())) {
            // 负责人精确匹配（团队负责人查询）
            queryWrapper.eq(WorkOrder::getManager, workOrderListDto.getManager());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getTeamCategory())) {
            // 处理团队分类匹配（如：技术组/客服组/外勤组）
            queryWrapper.eq(WorkOrder::getTeamCategory, workOrderListDto.getTeamCategory());
        }
        if (workOrderListDto.getProcessingStatus() != null) {
            // 工单处理状态匹配（如：0-未开始 1-进行中 2-已完成）
            queryWrapper.eq(WorkOrder::getProcessingStatus, workOrderListDto.getProcessingStatus());
        }
        if (workOrderListDto.getEndTime() != null) {
            // 实际结束时间范围查询（用于结单时间筛选）
            LocalDate endTime = workOrderListDto.getEndTime();
            LocalDateTime start = endTime.atStartOfDay();
            LocalDateTime end = endTime.atTime(LocalTime.MAX);
            queryWrapper.between(WorkOrder::getEndTime, start,end);
        }
        if (StringUtils.isNotBlank(workOrderListDto.getTargetUser())) {
            // 目标用户精确匹配（工单关联的目标用户）
            queryWrapper.eq(WorkOrder::getTargetUser, workOrderListDto.getTargetUser());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getTitle())) {
            // 工单标题模糊查询（支持关键词片段搜索）
            queryWrapper.like(WorkOrder::getTitle, workOrderListDto.getTitle());
        }
        if (workOrderListDto.getIsSensitive() != null) {
            // 是否敏感工单标记（特殊数据处理标识）
            queryWrapper.eq(WorkOrder::getIsSensitive, workOrderListDto.getIsSensitive());
        }
        if (StringUtils.isNotBlank(workOrderListDto.getTargetOrganization())) {
            // 目标机构精确匹配（如分行/支行编号）
            queryWrapper.eq(WorkOrder::getTargetOrganization, workOrderListDto.getTargetOrganization());
        }
        if (workOrderListDto.getExpectedEndTime() != null) {
            // 预期完成时间范围查询（用于时效性监控）
            LocalDate expectedEndTime = workOrderListDto.getExpectedEndTime();
            LocalDateTime start = expectedEndTime.atStartOfDay();
            LocalDateTime end = expectedEndTime.atTime(LocalTime.MAX);
            queryWrapper.between(WorkOrder::getExpectedEndTime, start,end);
        }
        queryWrapper.eq(WorkOrder::getIs_deleted,false);
        return queryWrapper;
    }
    private static LambdaUpdateWrapper<WorkOrder> getWorkOrderLambdaUpdateWrapper(WorkOrderUpdateDto workOrderUpdateDto) {
        LambdaUpdateWrapper<WorkOrder> updateWrapper = new LambdaUpdateWrapper<>();

        // 根据 uuid 定位要更新的工单
        updateWrapper.eq(WorkOrder::getUuid, workOrderUpdateDto.getUuid());
        /*
        if (workOrderUpdateDto.getAnnex()!=null) {
            //这里annex必须要使用实体类添加，否则类转化器不生效或者按照下面的代码手动转换
            String annex = String.valueOf(JSONUtil.parse(workOrderUpdateDto.getAnnex()));
            updateWrapper.set(WorkOrder::getAnnex, annex);
        }
         */
        if (StringUtils.isNotBlank(workOrderUpdateDto.getTargetOrganization())) {
            updateWrapper.set(WorkOrder::getTargetOrganization, workOrderUpdateDto.getTargetOrganization());
        }
        if (StringUtils.isNotBlank(workOrderUpdateDto.getReviewComment())) {
            updateWrapper.set(WorkOrder::getReviewComment, workOrderUpdateDto.getReviewComment());
        }
        updateWrapper.set(WorkOrder::getUpdateTime, LocalDateTime.now());
        return updateWrapper;
    }

}

